﻿@using NewLife;
@{
    var fmt = Model as String;
    var formatStr = !fmt.IsNullOrEmpty() ? fmt : "yyyy-MM-dd";
    var p = ViewBag.Page as Pager;

    var dataStart = p["dataStart"].ToDateTime();
    var dataEnd = p["dataEnd"].ToDateTime();
    var step = (Int32)(dataEnd - dataStart).TotalDays + 1;
}
<div class="form-group">
    <label for="dataStart" class="control-label">数据时间：</label>
    <div class="input-group">
        @if (formatStr == "yyyy-MM-dd" && (dataStart.Year > 2000 || dataEnd.Year > 2000))
        {
            var url = p.GetBaseUrl(true, true, true, new[] { "dataStart", "dataEnd" });
            if (dataStart.Year > 2000 && dataEnd.Year > 2000) url.UrlParam("dataStart", dataStart.AddDays(-step).ToString("yyyy-MM-dd"));
            if (dataStart.Year > 2000 && dataEnd.Year > 2000) url.UrlParam("dataEnd", dataEnd.AddDays(-step).ToString("yyyy-MM-dd"));
            <span class="input-group-addon"><a href="?@Html.Raw(url)" title="前一段"><i class="fa fa-calendar"></i></a></span>
        }
        else
        {
            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
        }
        <input name="dataStart" id="dataStart" value="@p["dataStart"]" dateformat="@formatStr" class="form-control form_datetime" autocomplete="off" />
    </div>
    @if (formatStr == "yyyy-MM-dd" && (dataStart.Year > 2000 || dataEnd.Year > 2000))
    {
        var url = p.GetBaseUrl(true, true, true, new[] { "dataStart", "dataEnd" });
        if (dataStart.Year > 2000 && dataEnd.Year > 2000) url.UrlParam("dataStart", dataStart.AddDays(step).ToString("yyyy-MM-dd"));
        if (dataStart.Year > 2000 && dataEnd.Year > 2000) url.UrlParam("dataEnd", dataEnd.AddDays(step).ToString("yyyy-MM-dd"));
        <label for="dataEnd" class="control-label"><a href="?@Html.Raw(url)" title="后一段">~</a></label>
    }
    else
    {
        <label for="dataEnd" class="control-label">~</label>
    }
    <div class="input-group">
        @*<span class="input-group-addon"><i class="fa fa-calendar"></i></span>*@
        <input name="dataEnd" id="dataEnd" value="@p["dataEnd"]" dateformat="@formatStr" class="form-control form_datetime" autocomplete="off" />
    </div>
</div>